"use strict";
Object.defineProperty(exports, "__esModule", { value: !0 });
const t = function(t, e, a, n) {
  const r = Math.round(n / 2) - 3;
  if (!(e && a && e.$y && a.$y)) return (t.$p = ""), t;
  let i = !1,
    s = !1;
  switch (t.type) {
    case 0:
      s = !0;
      break;
    case 1:
      (i = !0), (s = !0);
      break;
    case 3:
      i = !0;
  }
  const o = i ? e.$x : e.$x + e.$w,
    u = e.$y,
    c = s ? a.$x : a.$x + a.$w,
    d = a.$y;
  if (o !== c || u !== d) {
    const e = (function(t, e, a, n, r, i, s) {
        const o = t + 20 * (r ? -1 : 1),
          u = a + 20 * (i ? -1 : 1),
          c = [t, e, o, e, 0, 0, 0, 0, u, n, a, n],
          d = u - o;
        let l = n - e;
        const h = i === r;
        h || (((u <= t && i) || (u > t && !i)) && (l -= s));
        (h && i && o > u) || (h && !i && o < u)
          ? ((c[4] = c[2] + d), (c[5] = c[3]), (c[6] = c[4]), (c[7] = c[5] + l))
          : ((c[4] = c[2]),
            (c[5] = c[3] + l),
            (c[6] = c[4] + d),
            (c[7] = c[5]));
        return c.join(",");
      })(o, u + r, c, d + r, i, s, n / 2),
      a =
        ((l = c),
        (h = d + r),
        s
          ? `${l - 5},${h - 3},${l - 5},${h + 3},${l},${h}`
          : `${l + 5},${h + 3},${l + 5},${h - 3},${l},${h}`);
    t.$p = `${e},${a}`;
  }
  var l, h;
  return t;
};
function e(t) {
  if (null === t || !0 === t || !1 === t) return NaN;
  var e = Number(t);
  return isNaN(e) ? e : e < 0 ? Math.ceil(e) : Math.floor(e);
}
function a(t, e) {
  if (e.length < t)
    throw new TypeError(
      t +
        " argument" +
        (t > 1 ? "s" : "") +
        " required, but only " +
        e.length +
        " present"
    );
}
function n(t) {
  a(1, arguments);
  var e = Object.prototype.toString.call(t);
  return t instanceof Date || ("object" == typeof t && "[object Date]" === e)
    ? new Date(t.getTime())
    : "number" == typeof t || "[object Number]" === e
    ? new Date(t)
    : (("string" != typeof t && "[object String]" !== e) ||
        "undefined" == typeof console ||
        (console.warn(
          "Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://git.io/fjule"
        ),
        console.warn(new Error().stack)),
      new Date(NaN));
}
function r(t, r) {
  a(2, arguments);
  var i = n(t),
    s = e(r);
  return isNaN(s) ? new Date(NaN) : s ? (i.setDate(i.getDate() + s), i) : i;
}
function i(t, r) {
  a(2, arguments);
  var i = n(t),
    s = e(r);
  if (isNaN(s)) return new Date(NaN);
  if (!s) return i;
  var o = i.getDate(),
    u = new Date(i.getTime());
  u.setMonth(i.getMonth() + s + 1, 0);
  var c = u.getDate();
  return o >= c ? u : (i.setFullYear(u.getFullYear(), u.getMonth(), o), i);
}
function s(t, r) {
  a(2, arguments);
  var i = n(t).getTime(),
    s = e(r);
  return new Date(i + s);
}
function o(t) {
  return t.getTime() % 6e4;
}
function u(t) {
  var e = new Date(t.getTime()),
    a = Math.ceil(e.getTimezoneOffset());
  return e.setSeconds(0, 0), 6e4 * a + (a > 0 ? (6e4 + o(e)) % 6e4 : o(e));
}
function c(t) {
  a(1, arguments);
  var e = n(t);
  return e.setHours(0, 0, 0, 0), e;
}
function d(t, e) {
  a(2, arguments);
  var n = c(t),
    r = c(e),
    i = n.getTime() - u(n),
    s = r.getTime() - u(r);
  return Math.round((i - s) / 864e5);
}
function l(t, e) {
  a(2, arguments);
  var r = n(t),
    i = n(e),
    s = r.getTime() - i.getTime();
  return s < 0 ? -1 : s > 0 ? 1 : s;
}
function h(t) {
  a(1, arguments);
  var e = n(t);
  return !isNaN(e);
}
function f(t, e) {
  a(2, arguments);
  var r = n(t),
    i = n(e),
    s = r.getFullYear() - i.getFullYear(),
    o = r.getMonth() - i.getMonth();
  return 12 * s + o;
}
function g(t, e) {
  a(2, arguments);
  var r = n(t),
    i = n(e);
  return r.getFullYear() - i.getFullYear();
}
function m(t, e) {
  var a =
    t.getFullYear() - e.getFullYear() ||
    t.getMonth() - e.getMonth() ||
    t.getDate() - e.getDate() ||
    t.getHours() - e.getHours() ||
    t.getMinutes() - e.getMinutes() ||
    t.getSeconds() - e.getSeconds() ||
    t.getMilliseconds() - e.getMilliseconds();
  return a < 0 ? -1 : a > 0 ? 1 : a;
}
function w(t, e) {
  a(2, arguments);
  var r = n(t),
    i = n(e),
    s = m(r, i),
    o = Math.abs(d(r, i));
  r.setDate(r.getDate() - s * o);
  var u = m(r, i) === -s,
    c = s * (o - u);
  return 0 === c ? 0 : c;
}
function p(t, e) {
  a(2, arguments);
  var r = n(t),
    i = n(e);
  return r.getTime() - i.getTime();
}
function b(t) {
  a(1, arguments);
  var e = n(t);
  return e.setHours(23, 59, 59, 999), e;
}
function v(t) {
  a(1, arguments);
  var e = n(t),
    r = e.getMonth();
  return (
    e.setFullYear(e.getFullYear(), r + 1, 0), e.setHours(23, 59, 59, 999), e
  );
}
function k(t) {
  a(1, arguments);
  var e = n(t);
  return b(e).getTime() === v(e).getTime();
}
function y(t, e) {
  a(2, arguments);
  var r = n(t),
    i = n(e),
    s = l(r, i),
    o = Math.abs(f(r, i));
  1 === r.getMonth() && r.getDate() > 27 && r.setDate(30),
    r.setMonth(r.getMonth() - s * o);
  var u = l(r, i) === -s;
  k(n(t)) && 1 === o && 1 === l(t, i) && (u = !1);
  var c = s * (o - u);
  return 0 === c ? 0 : c;
}
var M = {
  lessThanXSeconds: {
    one: "less than a second",
    other: "less than {{count}} seconds",
  },
  xSeconds: { one: "1 second", other: "{{count}} seconds" },
  halfAMinute: "half a minute",
  lessThanXMinutes: {
    one: "less than a minute",
    other: "less than {{count}} minutes",
  },
  xMinutes: { one: "1 minute", other: "{{count}} minutes" },
  aboutXHours: { one: "about 1 hour", other: "about {{count}} hours" },
  xHours: { one: "1 hour", other: "{{count}} hours" },
  xDays: { one: "1 day", other: "{{count}} days" },
  aboutXWeeks: { one: "about 1 week", other: "about {{count}} weeks" },
  xWeeks: { one: "1 week", other: "{{count}} weeks" },
  aboutXMonths: { one: "about 1 month", other: "about {{count}} months" },
  xMonths: { one: "1 month", other: "{{count}} months" },
  aboutXYears: { one: "about 1 year", other: "about {{count}} years" },
  xYears: { one: "1 year", other: "{{count}} years" },
  overXYears: { one: "over 1 year", other: "over {{count}} years" },
  almostXYears: { one: "almost 1 year", other: "almost {{count}} years" },
};
function T(t) {
  return function(e) {
    var a = e || {},
      n = a.width ? String(a.width) : t.defaultWidth;
    return t.formats[n] || t.formats[t.defaultWidth];
  };
}
var _ = {
    date: T({
      formats: {
        full: "EEEE, MMMM do, y",
        long: "MMMM do, y",
        medium: "MMM d, y",
        short: "MM/dd/yyyy",
      },
      defaultWidth: "full",
    }),
    time: T({
      formats: {
        full: "h:mm:ss a zzzz",
        long: "h:mm:ss a z",
        medium: "h:mm:ss a",
        short: "h:mm a",
      },
      defaultWidth: "full",
    }),
    dateTime: T({
      formats: {
        full: "{{date}} 'at' {{time}}",
        long: "{{date}} 'at' {{time}}",
        medium: "{{date}}, {{time}}",
        short: "{{date}}, {{time}}",
      },
      defaultWidth: "full",
    }),
  },
  x = {
    lastWeek: "'last' eeee 'at' p",
    yesterday: "'yesterday at' p",
    today: "'today at' p",
    tomorrow: "'tomorrow at' p",
    nextWeek: "eeee 'at' p",
    other: "P",
  };
function D(t) {
  return function(e, a) {
    var n,
      r = a || {};
    if (
      "formatting" === (r.context ? String(r.context) : "standalone") &&
      t.formattingValues
    ) {
      var i = t.defaultFormattingWidth || t.defaultWidth,
        s = r.width ? String(r.width) : i;
      n = t.formattingValues[s] || t.formattingValues[i];
    } else {
      var o = t.defaultWidth,
        u = r.width ? String(r.width) : t.defaultWidth;
      n = t.values[u] || t.values[o];
    }
    return n[t.argumentCallback ? t.argumentCallback(e) : e];
  };
}
function C(t) {
  return function(e, a) {
    var n = String(e),
      r = a || {},
      i = r.width,
      s = (i && t.matchPatterns[i]) || t.matchPatterns[t.defaultMatchWidth],
      o = n.match(s);
    if (!o) return null;
    var u,
      c = o[0],
      d = (i && t.parsePatterns[i]) || t.parsePatterns[t.defaultParseWidth];
    return (
      (u =
        "[object Array]" === Object.prototype.toString.call(d)
          ? (function(t, e) {
              for (var a = 0; a < t.length; a++) if (e(t[a])) return a;
            })(d, function(t) {
              return t.test(c);
            })
          : (function(t, e) {
              // eslint-disable-next-line no-prototype-builtins
              for (var a in t) if (t.hasOwnProperty(a) && e(t[a])) return a;
            })(d, function(t) {
              return t.test(c);
            })),
      (u = t.valueCallback ? t.valueCallback(u) : u),
      {
        value: (u = r.valueCallback ? r.valueCallback(u) : u),
        rest: n.slice(c.length),
      }
    );
  };
}
var S,
  P = {
    code: "en-US",
    formatDistance: function(t, e, a) {
      var n;
      return (
        (a = a || {}),
        (n =
          "string" == typeof M[t]
            ? M[t]
            : 1 === e
            ? M[t].one
            : M[t].other.replace("{{count}}", e)),
        a.addSuffix ? (a.comparison > 0 ? "in " + n : n + " ago") : n
      );
    },
    formatLong: _,
    // eslint-disable-next-line no-unused-vars
    formatRelative: function(t, e, a, n) {
      return x[t];
    },
    localize: {
      // eslint-disable-next-line no-unused-vars
      ordinalNumber: function(t, e) {
        var a = Number(t),
          n = a % 100;
        if (n > 20 || n < 10)
          switch (n % 10) {
            case 1:
              return a + "st";
            case 2:
              return a + "nd";
            case 3:
              return a + "rd";
          }
        return a + "th";
      },
      era: D({
        values: {
          narrow: ["B", "A"],
          abbreviated: ["BC", "AD"],
          wide: ["Before Christ", "Anno Domini"],
        },
        defaultWidth: "wide",
      }),
      quarter: D({
        values: {
          narrow: ["1", "2", "3", "4"],
          abbreviated: ["Q1", "Q2", "Q3", "Q4"],
          wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"],
        },
        defaultWidth: "wide",
        argumentCallback: function(t) {
          return Number(t) - 1;
        },
      }),
      month: D({
        values: {
          narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
          abbreviated: [
            "Jan",
            "Feb",
            "Mar",
            "Apr",
            "May",
            "Jun",
            "Jul",
            "Aug",
            "Sep",
            "Oct",
            "Nov",
            "Dec",
          ],
          wide: [
            "January",
            "February",
            "March",
            "April",
            "May",
            "June",
            "July",
            "August",
            "September",
            "October",
            "November",
            "December",
          ],
        },
        defaultWidth: "wide",
      }),
      day: D({
        values: {
          narrow: ["S", "M", "T", "W", "T", "F", "S"],
          short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
          abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
          wide: [
            "Sunday",
            "Monday",
            "Tuesday",
            "Wednesday",
            "Thursday",
            "Friday",
            "Saturday",
          ],
        },
        defaultWidth: "wide",
      }),
      dayPeriod: D({
        values: {
          narrow: {
            am: "a",
            pm: "p",
            midnight: "mi",
            noon: "n",
            morning: "morning",
            afternoon: "afternoon",
            evening: "evening",
            night: "night",
          },
          abbreviated: {
            am: "AM",
            pm: "PM",
            midnight: "midnight",
            noon: "noon",
            morning: "morning",
            afternoon: "afternoon",
            evening: "evening",
            night: "night",
          },
          wide: {
            am: "a.m.",
            pm: "p.m.",
            midnight: "midnight",
            noon: "noon",
            morning: "morning",
            afternoon: "afternoon",
            evening: "evening",
            night: "night",
          },
        },
        defaultWidth: "wide",
        formattingValues: {
          narrow: {
            am: "a",
            pm: "p",
            midnight: "mi",
            noon: "n",
            morning: "in the morning",
            afternoon: "in the afternoon",
            evening: "in the evening",
            night: "at night",
          },
          abbreviated: {
            am: "AM",
            pm: "PM",
            midnight: "midnight",
            noon: "noon",
            morning: "in the morning",
            afternoon: "in the afternoon",
            evening: "in the evening",
            night: "at night",
          },
          wide: {
            am: "a.m.",
            pm: "p.m.",
            midnight: "midnight",
            noon: "noon",
            morning: "in the morning",
            afternoon: "in the afternoon",
            evening: "in the evening",
            night: "at night",
          },
        },
        defaultFormattingWidth: "wide",
      }),
    },
    match: {
      ordinalNumber:
        ((S = {
          matchPattern: /^(\d+)(th|st|nd|rd)?/i,
          parsePattern: /\d+/i,
          valueCallback: function(t) {
            return parseInt(t, 10);
          },
        }),
        function(t, e) {
          var a = String(t),
            n = e || {},
            r = a.match(S.matchPattern);
          if (!r) return null;
          var i = r[0],
            s = a.match(S.parsePattern);
          if (!s) return null;
          var o = S.valueCallback ? S.valueCallback(s[0]) : s[0];
          return {
            value: (o = n.valueCallback ? n.valueCallback(o) : o),
            rest: a.slice(i.length),
          };
        }),
      era: C({
        matchPatterns: {
          narrow: /^(b|a)/i,
          abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
          wide: /^(before christ|before common era|anno domini|common era)/i,
        },
        defaultMatchWidth: "wide",
        parsePatterns: { any: [/^b/i, /^(a|c)/i] },
        defaultParseWidth: "any",
      }),
      quarter: C({
        matchPatterns: {
          narrow: /^[1234]/i,
          abbreviated: /^q[1234]/i,
          wide: /^[1234](th|st|nd|rd)? quarter/i,
        },
        defaultMatchWidth: "wide",
        parsePatterns: { any: [/1/i, /2/i, /3/i, /4/i] },
        defaultParseWidth: "any",
        valueCallback: function(t) {
          return t + 1;
        },
      }),
      month: C({
        matchPatterns: {
          narrow: /^[jfmasond]/i,
          abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
          wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i,
        },
        defaultMatchWidth: "wide",
        parsePatterns: {
          narrow: [
            /^j/i,
            /^f/i,
            /^m/i,
            /^a/i,
            /^m/i,
            /^j/i,
            /^j/i,
            /^a/i,
            /^s/i,
            /^o/i,
            /^n/i,
            /^d/i,
          ],
          any: [
            /^ja/i,
            /^f/i,
            /^mar/i,
            /^ap/i,
            /^may/i,
            /^jun/i,
            /^jul/i,
            /^au/i,
            /^s/i,
            /^o/i,
            /^n/i,
            /^d/i,
          ],
        },
        defaultParseWidth: "any",
      }),
      day: C({
        matchPatterns: {
          narrow: /^[smtwf]/i,
          short: /^(su|mo|tu|we|th|fr|sa)/i,
          abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
          wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i,
        },
        defaultMatchWidth: "wide",
        parsePatterns: {
          narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
          any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i],
        },
        defaultParseWidth: "any",
      }),
      dayPeriod: C({
        matchPatterns: {
          narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
          any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i,
        },
        defaultMatchWidth: "any",
        parsePatterns: {
          any: {
            am: /^a/i,
            pm: /^p/i,
            midnight: /^mi/i,
            noon: /^no/i,
            morning: /morning/i,
            afternoon: /afternoon/i,
            evening: /evening/i,
            night: /night/i,
          },
        },
        defaultParseWidth: "any",
      }),
    },
    options: { weekStartsOn: 0, firstWeekContainsDate: 1 },
  };
function O(t, n) {
  a(2, arguments);
  var r = e(n);
  return s(t, -r);
}
function Y(t, e) {
  for (var a = t < 0 ? "-" : "", n = Math.abs(t).toString(); n.length < e; )
    n = "0" + n;
  return a + n;
}
var U = function(t, e) {
    var a = t.getUTCFullYear(),
      n = a > 0 ? a : 1 - a;
    return Y("yy" === e ? n % 100 : n, e.length);
  },
  $ = function(t, e) {
    var a = t.getUTCMonth();
    return "M" === e ? String(a + 1) : Y(a + 1, 2);
  },
  W = function(t, e) {
    return Y(t.getUTCDate(), e.length);
  },
  N = function(t, e) {
    return Y(t.getUTCHours() % 12 || 12, e.length);
  },
  j = function(t, e) {
    return Y(t.getUTCHours(), e.length);
  },
  E = function(t, e) {
    return Y(t.getUTCMinutes(), e.length);
  },
  F = function(t, e) {
    return Y(t.getUTCSeconds(), e.length);
  },
  q = function(t, e) {
    var a = e.length,
      n = t.getUTCMilliseconds();
    return Y(Math.floor(n * Math.pow(10, a - 3)), e.length);
  };
function L(t) {
  a(1, arguments);
  var e = 1,
    r = n(t),
    i = r.getUTCDay(),
    s = (i < e ? 7 : 0) + i - e;
  return r.setUTCDate(r.getUTCDate() - s), r.setUTCHours(0, 0, 0, 0), r;
}
function H(t) {
  a(1, arguments);
  var e = n(t),
    r = e.getUTCFullYear(),
    i = new Date(0);
  i.setUTCFullYear(r + 1, 0, 4), i.setUTCHours(0, 0, 0, 0);
  var s = L(i),
    o = new Date(0);
  o.setUTCFullYear(r, 0, 4), o.setUTCHours(0, 0, 0, 0);
  var u = L(o);
  return e.getTime() >= s.getTime()
    ? r + 1
    : e.getTime() >= u.getTime()
    ? r
    : r - 1;
}
function X(t) {
  a(1, arguments);
  var e = H(t),
    n = new Date(0);
  n.setUTCFullYear(e, 0, 4), n.setUTCHours(0, 0, 0, 0);
  var r = L(n);
  return r;
}
function z(t, r) {
  a(1, arguments);
  var i = r || {},
    s = i.locale,
    o = s && s.options && s.options.weekStartsOn,
    u = null == o ? 0 : e(o),
    c = null == i.weekStartsOn ? u : e(i.weekStartsOn);
  if (!(c >= 0 && c <= 6))
    throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");
  var d = n(t),
    l = d.getUTCDay(),
    h = (l < c ? 7 : 0) + l - c;
  return d.setUTCDate(d.getUTCDate() - h), d.setUTCHours(0, 0, 0, 0), d;
}
function G(t, r) {
  a(1, arguments);
  var i = n(t, r),
    s = i.getUTCFullYear(),
    o = r || {},
    u = o.locale,
    c = u && u.options && u.options.firstWeekContainsDate,
    d = null == c ? 1 : e(c),
    l = null == o.firstWeekContainsDate ? d : e(o.firstWeekContainsDate);
  if (!(l >= 1 && l <= 7))
    throw new RangeError(
      "firstWeekContainsDate must be between 1 and 7 inclusively"
    );
  var h = new Date(0);
  h.setUTCFullYear(s + 1, 0, l), h.setUTCHours(0, 0, 0, 0);
  var f = z(h, r),
    g = new Date(0);
  g.setUTCFullYear(s, 0, l), g.setUTCHours(0, 0, 0, 0);
  var m = z(g, r);
  return i.getTime() >= f.getTime()
    ? s + 1
    : i.getTime() >= m.getTime()
    ? s
    : s - 1;
}
function Q(t, n) {
  a(1, arguments);
  var r = n || {},
    i = r.locale,
    s = i && i.options && i.options.firstWeekContainsDate,
    o = null == s ? 1 : e(s),
    u = null == r.firstWeekContainsDate ? o : e(r.firstWeekContainsDate),
    c = G(t, n),
    d = new Date(0);
  d.setUTCFullYear(c, 0, u), d.setUTCHours(0, 0, 0, 0);
  var l = z(d, n);
  return l;
}
var A = "midnight",
  R = "noon",
  B = "morning",
  J = "afternoon",
  I = "evening",
  V = "night",
  K = {
    G: function(t, e, a) {
      var n = t.getUTCFullYear() > 0 ? 1 : 0;
      switch (e) {
        case "G":
        case "GG":
        case "GGG":
          return a.era(n, { width: "abbreviated" });
        case "GGGGG":
          return a.era(n, { width: "narrow" });
        case "GGGG":
        default:
          return a.era(n, { width: "wide" });
      }
    },
    y: function(t, e, a) {
      if ("yo" === e) {
        var n = t.getUTCFullYear(),
          r = n > 0 ? n : 1 - n;
        return a.ordinalNumber(r, { unit: "year" });
      }
      return U(t, e);
    },
    Y: function(t, e, a, n) {
      var r = G(t, n),
        i = r > 0 ? r : 1 - r;
      return "YY" === e
        ? Y(i % 100, 2)
        : "Yo" === e
        ? a.ordinalNumber(i, { unit: "year" })
        : Y(i, e.length);
    },
    R: function(t, e) {
      return Y(H(t), e.length);
    },
    u: function(t, e) {
      return Y(t.getUTCFullYear(), e.length);
    },
    Q: function(t, e, a) {
      var n = Math.ceil((t.getUTCMonth() + 1) / 3);
      switch (e) {
        case "Q":
          return String(n);
        case "QQ":
          return Y(n, 2);
        case "Qo":
          return a.ordinalNumber(n, { unit: "quarter" });
        case "QQQ":
          return a.quarter(n, { width: "abbreviated", context: "formatting" });
        case "QQQQQ":
          return a.quarter(n, { width: "narrow", context: "formatting" });
        case "QQQQ":
        default:
          return a.quarter(n, { width: "wide", context: "formatting" });
      }
    },
    q: function(t, e, a) {
      var n = Math.ceil((t.getUTCMonth() + 1) / 3);
      switch (e) {
        case "q":
          return String(n);
        case "qq":
          return Y(n, 2);
        case "qo":
          return a.ordinalNumber(n, { unit: "quarter" });
        case "qqq":
          return a.quarter(n, { width: "abbreviated", context: "standalone" });
        case "qqqqq":
          return a.quarter(n, { width: "narrow", context: "standalone" });
        case "qqqq":
        default:
          return a.quarter(n, { width: "wide", context: "standalone" });
      }
    },
    M: function(t, e, a) {
      var n = t.getUTCMonth();
      switch (e) {
        case "M":
        case "MM":
          return $(t, e);
        case "Mo":
          return a.ordinalNumber(n + 1, { unit: "month" });
        case "MMM":
          return a.month(n, { width: "abbreviated", context: "formatting" });
        case "MMMMM":
          return a.month(n, { width: "narrow", context: "formatting" });
        case "MMMM":
        default:
          return a.month(n, { width: "wide", context: "formatting" });
      }
    },
    L: function(t, e, a) {
      var n = t.getUTCMonth();
      switch (e) {
        case "L":
          return String(n + 1);
        case "LL":
          return Y(n + 1, 2);
        case "Lo":
          return a.ordinalNumber(n + 1, { unit: "month" });
        case "LLL":
          return a.month(n, { width: "abbreviated", context: "standalone" });
        case "LLLLL":
          return a.month(n, { width: "narrow", context: "standalone" });
        case "LLLL":
        default:
          return a.month(n, { width: "wide", context: "standalone" });
      }
    },
    w: function(t, e, r, i) {
      var s = (function(t, e) {
        a(1, arguments);
        var r = n(t),
          i = z(r, e).getTime() - Q(r, e).getTime();
        return Math.round(i / 6048e5) + 1;
      })(t, i);
      return "wo" === e ? r.ordinalNumber(s, { unit: "week" }) : Y(s, e.length);
    },
    I: function(t, e, r) {
      var i = (function(t) {
        a(1, arguments);
        var e = n(t),
          r = L(e).getTime() - X(e).getTime();
        return Math.round(r / 6048e5) + 1;
      })(t);
      return "Io" === e ? r.ordinalNumber(i, { unit: "week" }) : Y(i, e.length);
    },
    d: function(t, e, a) {
      return "do" === e
        ? a.ordinalNumber(t.getUTCDate(), { unit: "date" })
        : W(t, e);
    },
    D: function(t, e, r) {
      var i = (function(t) {
        a(1, arguments);
        var e = n(t),
          r = e.getTime();
        e.setUTCMonth(0, 1), e.setUTCHours(0, 0, 0, 0);
        var i = e.getTime(),
          s = r - i;
        return Math.floor(s / 864e5) + 1;
      })(t);
      return "Do" === e
        ? r.ordinalNumber(i, { unit: "dayOfYear" })
        : Y(i, e.length);
    },
    E: function(t, e, a) {
      var n = t.getUTCDay();
      switch (e) {
        case "E":
        case "EE":
        case "EEE":
          return a.day(n, { width: "abbreviated", context: "formatting" });
        case "EEEEE":
          return a.day(n, { width: "narrow", context: "formatting" });
        case "EEEEEE":
          return a.day(n, { width: "short", context: "formatting" });
        case "EEEE":
        default:
          return a.day(n, { width: "wide", context: "formatting" });
      }
    },
    e: function(t, e, a, n) {
      var r = t.getUTCDay(),
        i = (r - n.weekStartsOn + 8) % 7 || 7;
      switch (e) {
        case "e":
          return String(i);
        case "ee":
          return Y(i, 2);
        case "eo":
          return a.ordinalNumber(i, { unit: "day" });
        case "eee":
          return a.day(r, { width: "abbreviated", context: "formatting" });
        case "eeeee":
          return a.day(r, { width: "narrow", context: "formatting" });
        case "eeeeee":
          return a.day(r, { width: "short", context: "formatting" });
        case "eeee":
        default:
          return a.day(r, { width: "wide", context: "formatting" });
      }
    },
    c: function(t, e, a, n) {
      var r = t.getUTCDay(),
        i = (r - n.weekStartsOn + 8) % 7 || 7;
      switch (e) {
        case "c":
          return String(i);
        case "cc":
          return Y(i, e.length);
        case "co":
          return a.ordinalNumber(i, { unit: "day" });
        case "ccc":
          return a.day(r, { width: "abbreviated", context: "standalone" });
        case "ccccc":
          return a.day(r, { width: "narrow", context: "standalone" });
        case "cccccc":
          return a.day(r, { width: "short", context: "standalone" });
        case "cccc":
        default:
          return a.day(r, { width: "wide", context: "standalone" });
      }
    },
    i: function(t, e, a) {
      var n = t.getUTCDay(),
        r = 0 === n ? 7 : n;
      switch (e) {
        case "i":
          return String(r);
        case "ii":
          return Y(r, e.length);
        case "io":
          return a.ordinalNumber(r, { unit: "day" });
        case "iii":
          return a.day(n, { width: "abbreviated", context: "formatting" });
        case "iiiii":
          return a.day(n, { width: "narrow", context: "formatting" });
        case "iiiiii":
          return a.day(n, { width: "short", context: "formatting" });
        case "iiii":
        default:
          return a.day(n, { width: "wide", context: "formatting" });
      }
    },
    a: function(t, e, a) {
      var n = t.getUTCHours() / 12 >= 1 ? "pm" : "am";
      switch (e) {
        case "a":
        case "aa":
          return a.dayPeriod(n, {
            width: "abbreviated",
            context: "formatting",
          });
        case "aaa":
          return a
            .dayPeriod(n, { width: "abbreviated", context: "formatting" })
            .toLowerCase();
        case "aaaaa":
          return a.dayPeriod(n, { width: "narrow", context: "formatting" });
        case "aaaa":
        default:
          return a.dayPeriod(n, { width: "wide", context: "formatting" });
      }
    },
    b: function(t, e, a) {
      var n,
        r = t.getUTCHours();
      switch (
        ((n = 12 === r ? R : 0 === r ? A : r / 12 >= 1 ? "pm" : "am"), e)
      ) {
        case "b":
        case "bb":
          return a.dayPeriod(n, {
            width: "abbreviated",
            context: "formatting",
          });
        case "bbb":
          return a
            .dayPeriod(n, { width: "abbreviated", context: "formatting" })
            .toLowerCase();
        case "bbbbb":
          return a.dayPeriod(n, { width: "narrow", context: "formatting" });
        case "bbbb":
        default:
          return a.dayPeriod(n, { width: "wide", context: "formatting" });
      }
    },
    B: function(t, e, a) {
      var n,
        r = t.getUTCHours();
      switch (((n = r >= 17 ? I : r >= 12 ? J : r >= 4 ? B : V), e)) {
        case "B":
        case "BB":
        case "BBB":
          return a.dayPeriod(n, {
            width: "abbreviated",
            context: "formatting",
          });
        case "BBBBB":
          return a.dayPeriod(n, { width: "narrow", context: "formatting" });
        case "BBBB":
        default:
          return a.dayPeriod(n, { width: "wide", context: "formatting" });
      }
    },
    h: function(t, e, a) {
      if ("ho" === e) {
        var n = t.getUTCHours() % 12;
        return 0 === n && (n = 12), a.ordinalNumber(n, { unit: "hour" });
      }
      return N(t, e);
    },
    H: function(t, e, a) {
      return "Ho" === e
        ? a.ordinalNumber(t.getUTCHours(), { unit: "hour" })
        : j(t, e);
    },
    K: function(t, e, a) {
      var n = t.getUTCHours() % 12;
      return "Ko" === e ? a.ordinalNumber(n, { unit: "hour" }) : Y(n, e.length);
    },
    k: function(t, e, a) {
      var n = t.getUTCHours();
      return (
        0 === n && (n = 24),
        "ko" === e ? a.ordinalNumber(n, { unit: "hour" }) : Y(n, e.length)
      );
    },
    m: function(t, e, a) {
      return "mo" === e
        ? a.ordinalNumber(t.getUTCMinutes(), { unit: "minute" })
        : E(t, e);
    },
    s: function(t, e, a) {
      return "so" === e
        ? a.ordinalNumber(t.getUTCSeconds(), { unit: "second" })
        : F(t, e);
    },
    S: function(t, e) {
      return q(t, e);
    },
    X: function(t, e, a, n) {
      var r = (n._originalDate || t).getTimezoneOffset();
      if (0 === r) return "Z";
      switch (e) {
        case "X":
          return tt(r);
        case "XXXX":
        case "XX":
          return et(r);
        case "XXXXX":
        case "XXX":
        default:
          return et(r, ":");
      }
    },
    x: function(t, e, a, n) {
      var r = (n._originalDate || t).getTimezoneOffset();
      switch (e) {
        case "x":
          return tt(r);
        case "xxxx":
        case "xx":
          return et(r);
        case "xxxxx":
        case "xxx":
        default:
          return et(r, ":");
      }
    },
    O: function(t, e, a, n) {
      var r = (n._originalDate || t).getTimezoneOffset();
      switch (e) {
        case "O":
        case "OO":
        case "OOO":
          return "GMT" + Z(r, ":");
        case "OOOO":
        default:
          return "GMT" + et(r, ":");
      }
    },
    z: function(t, e, a, n) {
      var r = (n._originalDate || t).getTimezoneOffset();
      switch (e) {
        case "z":
        case "zz":
        case "zzz":
          return "GMT" + Z(r, ":");
        case "zzzz":
        default:
          return "GMT" + et(r, ":");
      }
    },
    t: function(t, e, a, n) {
      var r = n._originalDate || t;
      return Y(Math.floor(r.getTime() / 1e3), e.length);
    },
    T: function(t, e, a, n) {
      return Y((n._originalDate || t).getTime(), e.length);
    },
  };
function Z(t, e) {
  var a = t > 0 ? "-" : "+",
    n = Math.abs(t),
    r = Math.floor(n / 60),
    i = n % 60;
  if (0 === i) return a + String(r);
  var s = e || "";
  return a + String(r) + s + Y(i, 2);
}
function tt(t, e) {
  return t % 60 == 0 ? (t > 0 ? "-" : "+") + Y(Math.abs(t) / 60, 2) : et(t, e);
}
function et(t, e) {
  var a = e || "",
    n = t > 0 ? "-" : "+",
    r = Math.abs(t);
  return n + Y(Math.floor(r / 60), 2) + a + Y(r % 60, 2);
}
function at(t, e) {
  switch (t) {
    case "P":
      return e.date({ width: "short" });
    case "PP":
      return e.date({ width: "medium" });
    case "PPP":
      return e.date({ width: "long" });
    case "PPPP":
    default:
      return e.date({ width: "full" });
  }
}
function nt(t, e) {
  switch (t) {
    case "p":
      return e.time({ width: "short" });
    case "pp":
      return e.time({ width: "medium" });
    case "ppp":
      return e.time({ width: "long" });
    case "pppp":
    default:
      return e.time({ width: "full" });
  }
}
var rt = {
    p: nt,
    P: function(t, e) {
      var a,
        n = t.match(/(P+)(p+)?/),
        r = n[1],
        i = n[2];
      if (!i) return at(t, e);
      switch (r) {
        case "P":
          a = e.dateTime({ width: "short" });
          break;
        case "PP":
          a = e.dateTime({ width: "medium" });
          break;
        case "PPP":
          a = e.dateTime({ width: "long" });
          break;
        case "PPPP":
        default:
          a = e.dateTime({ width: "full" });
      }
      return a.replace("{{date}}", at(r, e)).replace("{{time}}", nt(i, e));
    },
  },
  it = ["D", "DD"],
  st = ["YY", "YYYY"];
function ot(t) {
  return -1 !== it.indexOf(t);
}
function ut(t) {
  return -1 !== st.indexOf(t);
}
function ct(t, e, a) {
  if ("YYYY" === t)
    throw new RangeError(
      "Use `yyyy` instead of `YYYY` (in `"
        .concat(e, "`) for formatting years to the input `")
        .concat(a, "`; see: https://git.io/fxCyr")
    );
  if ("YY" === t)
    throw new RangeError(
      "Use `yy` instead of `YY` (in `"
        .concat(e, "`) for formatting years to the input `")
        .concat(a, "`; see: https://git.io/fxCyr")
    );
  if ("D" === t)
    throw new RangeError(
      "Use `d` instead of `D` (in `"
        .concat(e, "`) for formatting days of the month to the input `")
        .concat(a, "`; see: https://git.io/fxCyr")
    );
  if ("DD" === t)
    throw new RangeError(
      "Use `dd` instead of `DD` (in `"
        .concat(e, "`) for formatting days of the month to the input `")
        .concat(a, "`; see: https://git.io/fxCyr")
    );
}
var dt = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,
  lt = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,
  ht = /^'([^]*?)'?$/,
  ft = /''/g,
  gt = /[a-zA-Z]/;
function mt(t, r, i) {
  a(2, arguments);
  var s = String(r),
    o = i || {},
    c = o.locale || P,
    d = c.options && c.options.firstWeekContainsDate,
    l = null == d ? 1 : e(d),
    f = null == o.firstWeekContainsDate ? l : e(o.firstWeekContainsDate);
  if (!(f >= 1 && f <= 7))
    throw new RangeError(
      "firstWeekContainsDate must be between 1 and 7 inclusively"
    );
  var g = c.options && c.options.weekStartsOn,
    m = null == g ? 0 : e(g),
    w = null == o.weekStartsOn ? m : e(o.weekStartsOn);
  if (!(w >= 0 && w <= 6))
    throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");
  if (!c.localize)
    throw new RangeError("locale must contain localize property");
  if (!c.formatLong)
    throw new RangeError("locale must contain formatLong property");
  var p = n(t);
  if (!h(p)) throw new RangeError("Invalid time value");
  var b = u(p),
    v = O(p, b),
    k = {
      firstWeekContainsDate: f,
      weekStartsOn: w,
      locale: c,
      _originalDate: p,
    },
    y = s
      .match(lt)
      .map(function(t) {
        var e = t[0];
        return "p" === e || "P" === e ? (0, rt[e])(t, c.formatLong, k) : t;
      })
      .join("")
      .match(dt)
      .map(function(e) {
        if ("''" === e) return "'";
        var a = e[0];
        if ("'" === a) return wt(e);
        var n = K[a];
        if (n)
          return (
            !o.useAdditionalWeekYearTokens && ut(e) && ct(e, r, t),
            !o.useAdditionalDayOfYearTokens && ot(e) && ct(e, r, t),
            n(v, e, c.localize, k)
          );
        if (a.match(gt))
          throw new RangeError(
            "Format string contains an unescaped latin alphabet character `" +
              a +
              "`"
          );
        return e;
      })
      .join("");
  return y;
}
function wt(t) {
  return t.match(ht)[1].replace(ft, "'");
}
const pt = {
    year: function(t, e) {
      a(2, arguments);
      var r = n(t),
        i = n(e),
        s = l(r, i),
        o = Math.abs(g(r, i));
      r.setFullYear("1584"), i.setFullYear("1584");
      var u = l(r, i) === -s,
        c = s * (o - u);
      return 0 === c ? 0 : c;
    },
    quarter: function(t, e) {
      a(2, arguments);
      var n = y(t, e) / 3;
      return n > 0 ? Math.floor(n) : Math.ceil(n);
    },
    month: y,
    week: function(t, e) {
      a(2, arguments);
      var n = w(t, e) / 7;
      return n > 0 ? Math.floor(n) : Math.ceil(n);
    },
    day: d,
    hour: function(t, e) {
      a(2, arguments);
      var n = p(t, e) / 36e5;
      return n > 0 ? Math.floor(n) : Math.ceil(n);
    },
  },
  bt = {
    year: function(t, n) {
      a(2, arguments);
      var r = e(n);
      return i(t, 12 * r);
    },
    month: i,
    week: function(t, n) {
      a(2, arguments);
      var i = e(n),
        s = 7 * i;
      return r(t, s);
    },
    day: r,
    hour: function(t, n) {
      a(2, arguments);
      var r = e(n);
      return s(t, 36e5 * r);
    },
  };
function vt(t) {
  return pt[t];
}
function kt(t) {
  return bt[t];
}
function yt(t, r) {
  let i;
  switch (t) {
    case "month":
      return new Date(r.getFullYear(), r.getMonth(), 1);
    case "year":
      return new Date(r.getFullYear(), 0, 1);
    case "week":
      return (function(t, r) {
        a(1, arguments);
        var i = r || {},
          s = i.locale,
          o = s && s.options && s.options.weekStartsOn,
          u = null == o ? 0 : e(o),
          c = null == i.weekStartsOn ? u : e(i.weekStartsOn);
        if (!(c >= 0 && c <= 6))
          throw new RangeError(
            "weekStartsOn must be between 0 and 6 inclusively"
          );
        var d = n(t),
          l = d.getDay(),
          h = (l < c ? 7 : 0) + l - c;
        return d.setDate(d.getDate() - h), d.setHours(0, 0, 0, 0), d;
      })(r, { weekStartsOn: 1 });
    case "day":
    case "hour":
      return (
        (i = new Date(r.getFullYear(), r.getMonth(), r.getDate())),
        i.setHours(0, 0, 0, 0),
        i
      );
    default:
      return new Date(r);
  }
}
const Mt = vt("day"),
  Tt = kt("day");
function _t(t, e, a, n, r) {
  const i = vt(
      (function(t) {
        const e = new Date();
        return t
          .map((t) => ({ item: t, len: kt(t.unit)(e, 1) }))
          .sort((t, e) => (t.len < e.len ? -1 : 1))[0].item;
      })(r).unit
    ),
    s = i(e, t) * a,
    o = n * r.length;
  return {
    rows: r.map((r) => {
      const s = [],
        o = kt(r.unit);
      let u = yt(r.unit, t);
      for (; u < e; ) {
        let n = o(u, r.step);
        u < t && (u = t), n > e && (n = e);
        const c = i(n, u) * a,
          d =
            "function" == typeof r.format
              ? r.format(u, n)
              : mt(u, r.format, { firstWeekContainsDate: 4, weekStartsOn: 1 });
        let l = "";
        r.css && (l += "function" == typeof r.css ? r.css(u) : r.css),
          s.push({ width: c, value: d, css: l }),
          (u = n);
      }
      return { cells: s, add: o, height: n };
    }),
    width: s,
    height: o,
    diff: i,
    start: t,
    end: e,
  };
}
function xt(t, e, a, n, r) {
  t.setAttribute("width", (e * n).toString()),
    t.setAttribute("height", (a * n).toString());
  const i = t.getContext("2d");
  return i.translate(-0.5, -0.5), (i.strokeStyle = r), i;
}
function Dt(t, e, a, n, r, i) {
  t.beginPath(),
    t.moveTo(n, r),
    t.lineTo(n, i),
    "full" === e && t.lineTo(a, i),
    t.stroke();
}
function Ct(t, e) {
  for (let a = 0; a < t.length; a++) {
    const n = t[a];
    (n.$level = e), n.data && Ct(n.data, e + 1);
  }
}
function St(t) {
  const e = [];
  return Pt(t[0].data, e), e;
}
function Pt(t, e) {
  t.forEach((t) => {
    e.push(t), !0 === t.open && Pt(t.data, e);
  });
}
function Ot(t, e, a) {
  let n = t[e];
  const r = t[n.parent],
    i = r.data.indexOf(n);
  return (
    (n = Object.assign(Object.assign({}, n), a)), (r.data[i] = t[e] = n), t
  );
}
const Yt = kt("day"),
  Ut = vt("day");
const $t = vt("day");
function Wt(t) {
  let e = !t.tagName && t.target ? t.target : t;
  for (; e; ) {
    if (e.getAttribute) {
      if (e.getAttribute("data-id")) return e;
    }
    e = e.parentNode;
  }
  return null;
}
(exports.LocalData = class {
  constructor(t, e) {
    (this._dispatch = t), (this._updater = e), (this._cache = []);
  }
  init(t) {
    const { tasks: e, links: a, start: n, end: r } = t;
    (this._data = this._data || {}),
      this._cache.tasks !== e &&
        ((this._data.tasks = e),
        (this._data.tasksMap = (function(t) {
          const e = { id: 0, $level: 0, data: [] },
            a = { 0: e };
          return (
            t.forEach((t) => {
              (a[t.id] = t),
                "string" == typeof t.start_date &&
                  (t.start_date = new Date(t.start_date)),
                "string" == typeof t.end_date &&
                  (t.end_date = new Date(t.end_date)),
                t.duration && (t.duration = 1 * t.duration),
                (t.parent = t.parent || 0),
                (t.open = t.open || !1),
                (t.data = null);
            }),
            t.forEach((t) => {
              const e = a[t.parent];
              e && (e.data || (e.data = []), e.data.push(t));
            }),
            Ct(e.data, 1),
            a
          );
        })(e))),
      this._cache.links !== a && (this._data.links = a),
      (this._cache = { links: a, tasks: e }),
      (n && r) || (this._autoScale = !0),
      (this._base = Object.assign({}, t)),
      (this._data.scales = null),
      (this._data.scales = this.calckScales(n, r)),
      this.initStore(),
      this.update({
        tasksMap: this._data.tasksMap,
        links: this._data.links,
        scales: this._data.scales,
      });
  }
  calckScales(t, e) {
    const { scales: a, cellWidth: n, scaleHeight: r } = this._base;
    let i = t,
      s = e;
    return (
      this._autoScale &&
        (function(t, e) {
          for (const a in t) e(t[a]);
        })(this._data.tasksMap, (t) => {
          (!i || t.start_date <= i) && (i = t.start_date),
            (!s || t.end_date >= s) && (s = t.end_date);
        }),
      i ? t !== i && (i = Yt(i, -1)) : (i = new Date()),
      s ? e !== s && (s = Yt(s, 1)) : (s = Yt(i, 30)),
      this._data.scales && t === i && e === s ? null : _t(i, s, n, r, a)
    );
  }
  updateScales() {
    const t = this._data.scales;
    if (this._autoScale) return this.calckScales(t.start, t.end);
  }
  getTask(t) {
    return this._data.tasksMap[t];
  }
  initStore() {
    const { scales: t, tasksMap: e } = this._data;
    this.state = { tasksMap: e, tasks: [], links: [], scales: t };
  }
  update(t) {
    t.tasksMap &&
      ((this._data.tasksMap = t.tasksMap), (t.tasks = St(this._data.tasksMap))),
      t.scales && (this._data.scales = t.scales),
      t.tasks &&
        ((this._data.tasks = this.calckTasks(t.tasks)),
        (t.links = t.links || this._data.links)),
      t.links && (this._data.links = this.calckLinks(t.links)),
      this.updateStore(t);
  }
  updateTask(t, e, a) {
    e.id && delete (e = Object.assign({ ID: e.id }, e)).id,
      this.action(t, "update-task", e, a);
  }
  updateLink(t, e, a) {
    e.id && delete (e = Object.assign({ ID: e.id }, e)).id,
      this.action(t, "update-link", e, a);
  }
  updateStore(t) {
    const e = this.state,
      a = this._data,
      n = t;
    for (const t in n) n[t] && e[t] && (e[t] = a[t]);
  }
  dispatch(t, e, a) {
    a || this._dispatch(t, e);
  }
  calckTasks(t) {
    const { cellHeight: e, cellWidth: a } = this._base;
    return (t || St(this._data.tasksMap)).map((t, n) =>
      (function(t, e, a, n, r) {
        const { start: i, end: s, diff: o } = r;
        t.duration
          ? t.end_date || (t.end_date = Tt(t.start_date, t.duration))
          : t.end_date
          ? (t.duration = Mt(t.end_date, t.start_date))
          : (t.end_date = t.start_date);
        const u = t.start_date < i ? i : t.start_date,
          c = t.end_date > s ? s : t.end_date;
        return (
          (t.$x = o(u, i) * a),
          (t.$y = n * e + 3),
          (t.$w = o(c, u) * a),
          (t.$h = n - 7),
          "milestone" === t.type && ((t.$x = t.$x - t.$h / 2), (t.$w = t.$h)),
          t
        );
      })(t, n, a, e, this._data.scales)
    );
  }
  calckLinks(e) {
    const { tasksMap: a } = this._data;
    return (e || this._data.links)
      .map((e) => {
        const n = a[e.source],
          r = a[e.target];
        return t(e, n, r, this._base.cellHeight);
      })
      .filter((t) => null !== t);
  }
  action(t, e, a, n) {
    const { links: r, tasksMap: i } = this._data;
    let s, o, u, c;
    switch (e) {
      case "delete-link":
        (s = r.find((e) => e.id == t)),
          this.update({ links: r.filter((e) => e.id != t) }),
          this.dispatch("save", { action: e, obj: s }, n);
        break;
      case "update-link": {
        const i = r.findIndex((e) => e.id == t);
        (r[i] = Object.assign(Object.assign({}, r[i]), a)),
          this.update({ links: r }),
          this.dispatch("save", { action: e, obj: s }, n);
        break;
      }
      case "toggle-task":
        for (const t in i) i[t].$y = 0;
        Ot(i, t, { open: !i[t].open }), this.update({ tasksMap: i });
        break;
      case "repaint-task":
        this.update({ tasksMap: i });
        break;
      case "reorder-task": {
        let { mode: r, target: s } = a;
        if ("after" === r) {
          const t = i[s];
          t.open &&
            t.data.length &&
            ((a.mode = r = "before"), (a.target = s = t.data[0].id));
        }
        const o = (function(t, e, a, n) {
          const r = t[e],
            i = t[n];
          if (!r || !i) return;
          const s = t[r.parent],
            o = t[i.parent],
            u = s.data.indexOf(r);
          s.data.splice(u, 1);
          const c = o.data.indexOf(i) + ("after" === a ? 1 : 0);
          return (
            o.data.splice(c, -1, r),
            s === o && u === c
              ? null
              : ((r.parent = o.id),
                r.$level !== i.$level && Ct([r], i.$level),
                t)
          );
        })(i, t, r, s);
        this.update({ tasksMap: i }),
          o && this.dispatch("save", { action: e, obj: a }, n);
        break;
      }
      case "add-link":
        (s = Object.assign(Object.assign({}, a), { id: new Date().valueOf() })),
          r.push(s),
          this.update({ links: r }),
          this.dispatch("save", { action: e, obj: s }, n);
        break;
      case "update-task":
        Ot(i, t, a),
          (c = this.updateScales()),
          this.update({ tasksMap: i, scales: c }),
          this.dispatch("save", { action: e, obj: i[t] }, n);
        break;
      case "move-task": {
        const { width: e, left: n, top: r } = a;
        o = i[t];
        const s = {};
        void 0 !== e && (o.$w = e),
          void 0 !== n && (o.$x = n),
          void 0 !== r && ((o.$y = r + 4), (s.tasks = this._data.tasks)),
          (s.links = this._data.links = this.calckLinks()),
          this.updateStore(s);
        break;
      }
      case "update-task-time": {
        const { mode: e, time: r } = a;
        (o = i[t]),
          "start" === e &&
            ((o.start_date = Yt(o.start_date, r)),
            (o.duration = Ut(o.end_date, o.start_date))),
          "end" === e &&
            ((o.end_date = Yt(o.end_date, r)),
            (o.duration = Ut(o.end_date, o.start_date))),
          "move" === e &&
            ((o.start_date = Yt(o.start_date, r)),
            (o.end_date = Yt(o.end_date, r))),
          Ot(i, t, o),
          (c = this.updateScales()),
          this.update({ tasksMap: i, scales: c }),
          this.dispatch("save", { action: "update-task", obj: o }, n);
        break;
      }
      case "add-task": {
        const a = i[t],
          r = a.$level
            ? new Date(a.start_date.valueOf())
            : Yt(this._data.scales.start, 1),
          s = Yt(r, 1),
          o = {
            id: new Date().valueOf(),
            text: "New Task",
            details: "",
            start_date: r,
            end_date: s,
            progress: 0,
            parent: t,
            $level: a.$level + 1,
            data: null,
            open: !1,
          };
        a.data || (a.data = []),
          a.data.push(o),
          (a.open = !0),
          (i[o.id] = o),
          (u = o.id),
          (c = this.updateScales()),
          this.update({ tasksMap: i, scales: c }),
          this.dispatch(
            "save",
            { action: e, obj: o, get: () => this.getTask(o.id), mode: "last" },
            n
          );
        break;
      }
      case "delete-task":
        (o = i[t]),
          (function(t, e) {
            const a = t[e],
              n = t[a.parent];
            (n.data = n.data.filter((t) => t !== a)), delete t[e];
          })(i, t),
          this.update({
            tasksMap: i,
            links: r.filter((e) => e.source != t && e.target != t),
          }),
          this.dispatch("save", { action: e, obj: o }, n);
    }
    return u;
  }
}),
  (exports.LocalState = class {
    constructor(t) {
      (this._state = {
        scrollTop: t(0, "scrollTop"),
        scrollLeft: t(0, "scrollLeft"),
        dataStart: t(0, "dataStart"),
        dataEnd: t(0, "dataEnd"),
        from: t(0, "from"),
        details: t(null, "details"),
        selected: t(null, "selected"),
      }),
        this._state.selected.subscribe((t) => (this._selected = t)),
        this._state.details.subscribe((t) => (this._details = t));
    }
    getState() {
      return this._state;
    }
    actions(t, e, a) {
      const {
          details: n,
          selected: r,
          scrollTop: i,
          scrollLeft: s,
          dataStart: o,
          dataEnd: u,
          from: c,
        } = this._state,
        d = (e) => {
          n.set(Object.assign({}, t.getTask(e)));
        };
      return (l) => {
        const { id: h, action: f, obj: g } = l;
        let m = null;
        switch (f) {
          case "show-details":
            d(h);
            break;
          case "hide-details":
            n.set(null), r.set(null);
            break;
          case "select-task":
            r.set(t.getTask(h)), this._details && this._details.id != h && d(h);
            break;
          case "toggle-task":
            t.action(h, f, g), r.set(t.getTask(h));
            break;
          case "update-task-time":
            t.action(h, f, g), this._details && this._details.id == h && d(h);
            break;
          case "add-task":
            (m = t.action(h, f, g)),
              a().then(() => {
                r.set(t.getTask(m)), d(m);
              });
            break;
          case "delete-task":
            t.action(h, f, g), this._selected.id == h && r.set(null);
            break;
          case "scroll-chart": {
            const { left: t, top: e } = l;
            isNaN(t) || s.set(t), isNaN(e) || i.set(e);
            break;
          }
          case "data-request":
            o.set(l.start), u.set(l.end), c.set(l.from);
            break;
          default:
            t.action(h, f, g);
        }
        e("action", Object.assign(Object.assign({}, l), { nId: m }));
      };
    }
  }),
  (exports.getAdder = kt),
  (exports.getDiffer = vt),
  (exports.grid = function(t, e, a, n) {
    const r = document.createElement("canvas");
    if (
      !document.location.host.match(
        new RegExp(
          atob(
            "KF58XC4pKGRodG1seFwuY29tfGdpdGh1YlwuY29tfGdpdGh1YlwuaW98c3RhY2tibGl6XC5jb218c3ZlbHRlXC5kZXYpJA=="
          )
        )
      )
    ) {
      const i = xt(r, t, e, 3, a);
      for (let a = 0; a < 3; a++)
        for (let r = 0; r < 3; r++)
          Dt(i, n, t * a, t * (a + 1), e * r, e * (r + 1));
      const s = new Date().valueOf() > 1634909021979;
      return (
        (i.font = "10px monospace"),
        (i.fillStyle = s ? "#ff0000" : "#CCCCCC"),
        i.translate(1.5 * t, 1.5 * e),
        i.rotate(Math.PI / 6),
        i.fillText(s ? "" : "", -15, 4),
        r.toDataURL()
      );
    }
    return Dt(xt(r, t, e, 1, a), n, 0, t, 0, e), r.toDataURL();
  }),
  (exports.locate = Wt),
  (exports.locateID = function(t) {
    const e = Wt(t);
    return e ? e.getAttribute("data-id") : null;
  }),
  (exports.normalizeColumns = function(t) {
    return t.map((t) => {
      const e =
          "number" == typeof t.width ? t.width + "px" : t.width || "120px",
        a = t.align || "left";
      let n = t.template;
      if (!n)
        switch (t.name) {
          case "start":
            n = (t) => mt(t.start_date, "yyyy-MM-dd");
            break;
          case "end":
            n = (t) => mt(t.end_date, "yyyy-MM-dd");
            break;
          case "add-task":
            n = () => "add";
            break;
          case "duration":
            n = (t) => $t(t.end_date, t.start_date).toString();
            break;
          default:
            n = (e) => e[t.name];
        }
      const r = Object.assign(Object.assign({}, t), {
        width: e,
        align: a,
        template: n,
      });
      return "add-task" === r.name && (r.action = r.name), r;
    });
  }),
  (exports.placeLink = function(t, e, a) {
    if (e && a) {
      const n = a.x - e.x,
        r = a.y - e.y,
        i = (n > 0 ? e.x : a.x) - t.left,
        s = (r > 0 ? e.y : a.y) - t.top,
        o = `${n > 0 ? 0 : -n},${r > 0 ? 0 : -r},${n > 0 ? n : 0},${
          r > 0 ? r : 0
        }`;
      return { width: Math.abs(n), height: Math.abs(r), left: i, top: s, p: o };
    }
    return null;
  });
